/*
 * Copyright (c) 2010 Nokia Corporation.
 */

#ifndef GAMEENGINE_H
#define GAMEENGINE_H

#include <QObject>
#include <QDeclarativeItem>
#include <QMutex>
#include <QPluginLoader>
#include <QList>

#ifdef Q_OS_SYMBIAN
#include <hwrmvibra.h>
#endif


class GameEngine : public QObject
{
    Q_OBJECT

public:
    GameEngine(QObject* parent);
    ~GameEngine();

    Q_PROPERTY(int hiScore READ hiScore WRITE setHiScore)
public:
    Q_INVOKABLE QVariant randInt(QVariant low, QVariant high);
    Q_INVOKABLE void findQmlObjects();
    Q_INVOKABLE void clearQmlObjects();
    Q_INVOKABLE void findObjects(QObject *rootObject, const QString& objName, QObjectList& res);
    Q_INVOKABLE void doFrame();

    Q_INVOKABLE QVariant isSymbian();
    Q_INVOKABLE QVariant isMaemo();
    Q_INVOKABLE QVariant isWindows();

    Q_INVOKABLE void vibra();
    Q_INVOKABLE void fastVibra();


signals:
    void collision(QObject* a, QObject* b);

private slots:

public:
    void setGameQml(QObject* o);

    int hiScore() const;

public slots:

    void setHiScore(int arg);

private:
    void findEnemies(QObject* rootObject);


    void setMyShipQml(QObject* o);

private:
    void doHitTest();

private:
    QList<QDeclarativeItem*>    m_enemyList;
    QList<QDeclarativeItem*>    m_missileList;

    QDeclarativeItem*           m_GameGml;
    QDeclarativeItem*           m_myShipGml;


    int                         m_timerId;
    int                         m_doEnemyMissile;

#ifdef Q_OS_SYMBIAN
    CHWRMVibra* iVibrate;
#endif

    int m_hiScore;
};

#endif // GAMEENGINE_H
